﻿<!DOCTYPE html>

<html lang="en">
<head>
    <meta charset="utf-8" />
    <title>Egret Physics</title>
    <link rel="stylesheet" href="app.css" type="text/css" />
</head>
<body id="main">
    <div id="panel">
        <h1>
            <a>Egret3d</a> - Physics
        </h1>
        <div id="content">
        </div>
    </div>
    <iframe id="viewer" name="viewer"></iframe>
    <script>

        var links = {};
        var selected = null;
        var path = "";

        var content = document.getElementById("content");
        var container = document.createElement("div");
        var viewer = document.getElementById("viewer");

        content.appendChild(container);

        if (/(iPad|iPhone|iPod)/g.test(navigator.userAgent)) {
            viewer.style.width = getComputedStyle(viewer).width;
            viewer.style.height = getComputedStyle(viewer).height;
            viewer.setAttribute("scrolling", "no");
        }

        var array = [
            ["基本场景", "basicview"],
            ["鼠标拾取", "mousepick"],
            ["车辆控制", "raycastvehicle"],
            ["高低地形", "heightfield"]
        ]

        for (var key in array) {
            var link = document.createElement("a");
            link.className = "link";
            link.textContent = array[key][0];
            link.setAttribute("target", "viewer");
            link.href = "sample/" + array[key][1];

            link.addEventListener("click", (event) => {
                if (event.button === 0) {
                    if (selected !== null) {
                        selected.className = "link";
                    }

                    event.currentTarget.classList.add("selected");
                    viewer.focus();
                    //button.style.display = "";

                    selected = event.currentTarget;

                    path = link.href;
                }
            }, false);

            container.appendChild(link);
        }

        //var button = document.createElement("div");
        //button.id = "button";
        //button.textContent = "View Source";
        //button.addEventListener("click", function (event) {
        //    var w = window.open(path + "/app.ts");
        //}, false);
        //button.style.display = "none";
        //document.body.appendChild(button);

    </script>
</body>
</html>
